import { Item } from "../../shared/face/index";
import { BaseBody } from '../../core/rpg';
import { BagFuncResult } from './types';
import { ComType } from "../../core/tool/component";
import follow_component from "../../component/follow_component";

/**
 * AddPet 功能 孵化宠物
 * @param useItem 使用的物品
 * @param useCount 使用数量
 * @param funcData 函数数据
 * @param player 玩家对象
 * @returns 使用结果
 */
export async function AddPet(useItem: Item, useCount: number, funcData: any, player: BaseBody): Promise<BagFuncResult> {
    try {
        // TODO: 实现具体逻辑

        const followCom = player.getComponent(ComType.随从) as follow_component;
        followCom.client_add(funcData);
        return {
            success: true,
            message: '功能执行成功',
            data: { action: 'AddPet' }
        };
    } catch (error: any) {
        return {
            success: false,
            message: '功能执行失败',
            data: { error: error.message }
        };
    }
}
